<template>
  <!-- 历史付款记录详情-->
  <el-dialog
    :title="title"
    center
    :visible.sync="openState"
    width="1024px"
    :close-on-click-modal="false"
    :before-close="handleClose"
  >
    <el-form ref="detailForm" :model="detailForm" disabled label-width="110px">
      <el-card class="form-card payeeInfo-card">
        <div slot="header" class="label-header-msg">
          <span>基本信息</span>
        </div>
        <el-row :gutter="10">
          <el-col :span="12">
            <div class="grid-payee">
              <el-form-item label="客户账号" prop="actNo">
                <acct-no-input
                  v-model="detailForm.actNo"
                  placeholder="客户账号"
                  :disabled="true"
                />
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-form-item label="客户名称" prop="name">
          <el-input v-model="detailForm.name" placeholder="客户名称"/>
        </el-form-item>
        <el-form-item label="客户地址" prop="addr">
          <el-input v-model="detailForm.addr" placeholder="客户地址"/>
        </el-form-item>
        <el-row :gutter="10">
          <el-col :span="12">
            <div class="grid-payee">
              <el-form-item label="收款行行号" prop="rcvBrno">
                <BrnoInput
                  v-model="detailForm.rcvBrno"
                  placeholder="收款行行号"
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款行行名" prop="rcvBrname" label-width="130px">
              <el-input v-model="detailForm.rcvBrname" placeholder="收款行行名" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <div class="grid-payee">
              <el-form-item label="收款人开户行号" prop="accBrno">
                <BrnoInput
                  v-model="detailForm.accBrno"
                  placeholder="收款人开户行行号"
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款人开户行行名" prop="accBrnoName" label-width="130px">
              <el-input v-model="detailForm.accBrnoName" placeholder="收款人开户行行名" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <!--审核信息-->
      <el-card class="form-card bankInfo-card">
        <div slot="header" class="label-header-msg">
          <span>处理信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="交易流水号" prop="id">
              <el-input v-model="detailForm.id" placeholder="交易流水号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="维护类型" prop="optType">
              <el-select v-model="detailForm.optType" placeholder="维护类型" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.BRANCH_OP_TYPE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核状态" prop="optStatus">
              <el-select v-model="detailForm.optStatus" placeholder="审核状态" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.ORGAN_OP_STATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="录入操作员" prop="creater">
              <el-input v-model="detailForm.creater" placeholder="录入操作员" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="录入时间" prop="createdDate">
              <el-date-picker
                style="width: 100%"
                v-model="detailForm.createdDate"
                value-format="yyyyMMddHHmmss"
                type="datetime"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="approve">审 核</el-button>
      <el-button type="primary" @click="reject">拒 绝</el-button>
      <el-button type="primary" @click="cancel">关 闭</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { listPageMixin } from "@/libs/listPageMixin";
import BrnoInput from "@/views/components/BrnoInput";
import AcctNoInput from "@/views/components/AcctNoInput";
import BankBranchDialog from "@/views/components/BankBranchDialog";
import { payinfoApprove, payinfoReject } from "@/api/cnaps/bizMng/payinfo";
export default {
  name: "payinfoApproveDetail",
  mixins: [listPageMixin],
  components: {
    BankBranchDialog,
    AcctNoInput,
    BrnoInput,
  },
  props: {

  },
  data() {
    return {
      title: "",
      // 是否显示弹出层
      openState: false,
      // 字段可编辑控制

      //数据字典
      searchFormDictList: [
        "BRANCH_OP_TYPE","ORGAN_OP_STATUS"
      ],
      // 表单参数
      detailForm: {
      },
      opButtonList: () => {
        return [
        ];
      },
    };
  },
  mounted() {
  },
  methods: {
    // 表单重置
    reset() {
      this.resetForm("detailForm");
      this.$set(this, "detailForm", {});
    },
    // 关闭回掉
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then(_ => {
          this.reset();
          done();
        })
        .catch(_ => {});
    },
    show(row) {
      this.detailForm = row;
      this.title = "历史付款记录维护审核明细";
      this.openState = true;
    },

    cancel() {
      this.openState = false;
      this.reset();
    },

    /** TODO审批按钮 */
    approve() {
      this.$refs["detailForm"].validate((valid) => {
        if (valid) {
          payinfoApprove(this.detailForm).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("审批通过");
              this.$emit("editComplete", true);
              this.cancel();
            }
          });
        }
      });
    },

    /** TODO拒绝按钮 */
    reject() {
      this.$refs["detailForm"].validate((valid) => {
        if (valid) {
          payinfoReject(this.detailForm).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("审批已拒绝");
              this.$emit("editComplete", true);
              this.cancel();
            }
          });
        }
      });
    },

  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
